<template>
	<view>
		<putongUser v-if="userInfo.qi_status == 0||!isLogin" :userInfo="userInfo" :isLogin="isLogin"></putongUser>
		<qishouUser v-else-if="userInfo.qi_status == 1" :userInfo="qiInfo" :isLogin="isLogin" @loginOut="loginOut">
		</qishouUser>
	</view>
</template>
<script>
	import putongUser from '@/components/putongUser'
	import qishouUser from '@/components/qishouUser'
	export default {
		components: {
			putongUser,
			qishouUser
		},
		data() {
			return {
				isLogin: false,
				userInfo: null,
				qiInfo: null,
			}
		},
		onShow() {
			console.log(123);
			if (uni.getStorageSync('userToken')) {
				this.isLogin = true
				this.getData()
			} else {
				this.isLogin = false
				this.userInfo = null
				this.userInfos = null
			}
		},
		methods: {
			loginOut() {
				this.getData()
			},
			getData() {
				this.$allApi.getUserInfo().then(res => {
					console.log(res.data);
					this.userInfo = res.data
					if (this.userInfo.qi_status == 1) {
						this.getQiInfo()
					}
					// this.userInfos = res.data.user.
					// if (res.data.user.type_title.length > 0) {
					// 	this.isRenzheng = true
					// }
				})
			},
			getQiInfo() {
				this.$allApi.getQiInfo().then(res => {
					this.qiInfo = res.data
				})
			},
		}
	}
</script>